package teacher.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import teacher.bean.Award;
import teacher.bean.Teacher;
import teacher.page.Page;
import teacher.page.PageUtil;
import teacher.service.award;
import teacher.service.treatise;
import tools.StringDate;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class searchAwaTim extends ActionSupport{
	
	private List<Award> awards;
	private String date1;
	private String date2;
	private int currentPage;

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public List<Award> getAwards() {
		return awards;
	}

	public void setAwards(List<Award> awards) {
		this.awards = awards;
	}

	public String getDate1() {
		return date1;
	}

	public void setDate1(String date1) {
		this.date1 = date1;
	}

	public String getDate2() {
		return date2;
	}

	public void setDate2(String date2) {
		this.date2 = date2;
	}

	public String execute()
	{
		ActionContext.getContext().put("flag", 1);
		ActionContext.getContext().put("date11", this.getDate1());
		ActionContext.getContext().put("date22", this.getDate2());
		
		ActionContext.getContext().put("date111", this.getDate1());
		ActionContext.getContext().put("date222", this.getDate2());
		
		HttpServletRequest request=ServletActionContext.getRequest();
		Teacher tea=(Teacher)request.getSession().getAttribute("teacher");
		
		// 获得记录数
				int totalCount = new award().getCountAwardTeaTime(tea,StringDate.StringToDate(this.getDate1()),
						StringDate.StringToDate(this.getDate2()));
				// 设置分页信息
				Page page = PageUtil.createPage(10, totalCount, currentPage);
		
		//通过日期来查找所有的专利
		awards=new award().selectTimeAwardTeaPage(tea,
				StringDate.StringToDate(this.getDate1()),
				StringDate.StringToDate(this.getDate2()),page);
		
		request.setAttribute("awards",awards);
		request.setAttribute("page",page);

		return SUCCESS;
	}


}

